/*
 * Coordonnees.cpp
 *
 *  Created on: Jun 8, 2013
 *      Author: juliendubois
 */

#include "Coordonnees.h"

Coordonnees::Coordonnees(int x, int y, int z) {
	this->x = x;
	this->y = y;
	this->z = z;
}

Coordonnees::Coordonnees(const Coordonnees& coord) {
	this->x = coord.x;
	this->y = coord.y;
	this->z = coord.z;
}

Coordonnees::~Coordonnees() {
}

Coordonnees& Coordonnees::getVoisin(Cardinalite_2D card) const {
	return	(card == Cardinalite_2D::Nord)		?	*(new Coordonnees(this->x,		this->y+1,	this->z)) :
			(card == Cardinalite_2D::NordEst)	?	*(new Coordonnees(this->x+1,	this->y+1,	this->z)) :
			(card == Cardinalite_2D::SudEst)	?	*(new Coordonnees(this->x+1,	this->y,	this->z)) :
			(card == Cardinalite_2D::Sud)		?	*(new Coordonnees(this->x,		this->y-1,	this->z)) :
			(card == Cardinalite_2D::SudOuest)	?	*(new Coordonnees(this->x-1,	this->y-1,	this->z)) :
													*(new Coordonnees(this->x-1,	this->y,	this->z));
}

Coordonnees& Coordonnees::getVoisin(Cardinalite_3D card) const {
	return	(card == Cardinalite_3D::Haut)	?	*(new Coordonnees(this->x, this->y, this->z+1)) :
												*(new Coordonnees(this->x, this->y, this->z-1)) ;
}

Coordonnees& Coordonnees::operator =(const Coordonnees& coord) {
	this->x = coord.x;
	this->y = coord.y;
	this->z = coord.z;
	return *this;
}

Coordonnees& Coordonnees::operator +=(const Coordonnees& coord) {
	this->x += coord.x;
	this->y += coord.y;
	this->z += coord.z;
	return *this;
}

Coordonnees& Coordonnees::operator -=(const Coordonnees& coord) {
	this->x -= coord.x;
	this->y -= coord.y;
	this->z -= coord.z;
	return *this;
}

Coordonnees & Coordonnees::operator+ (const Coordonnees & coord) const {
	return *(new Coordonnees(this->x + coord.x, this->y + coord.y, this->z + coord.z));
}

Coordonnees & Coordonnees::operator- (const Coordonnees & coord) const {
	return *(new Coordonnees(this->x - coord.x, this->y - coord.y, this->z - coord.z));
}

bool Coordonnees::operator ==(const Coordonnees& coord) const {
	return (this->x == coord.x) && (this->y == coord.y) && (this->z == coord.z);
}

bool Coordonnees::operator !=(const Coordonnees& coord) const {
	return (this->x != coord.x) || (this->y != coord.y) || (this->z != coord.z);
}

bool Coordonnees::operator <(const Coordonnees& coord) const {
	return	(this->x != coord.x) ?	(this->x < coord.x) :
			(this->y != coord.y) ?	(this->y < coord.y) :
									(this->z < coord.z) ;
}

bool Coordonnees::operator <=(const Coordonnees& coord) const {
	return	(this->x != coord.x) ?	(this->x < coord.x) :
			(this->y != coord.y) ?	(this->y < coord.y) :
									(this->z <= coord.z) ;
}

bool Coordonnees::operator >(const Coordonnees& coord) const {
	return	(this->x != coord.x) ?	(this->x > coord.x) :
			(this->y != coord.y) ?	(this->y > coord.y) :
									(this->z > coord.z) ;
}

bool Coordonnees::operator >=(const Coordonnees& coord) const {
	return	(this->x != coord.x) ?	(this->x > coord.x) :
			(this->y != coord.y) ?	(this->y > coord.y) :
									(this->z >= coord.z) ;
}
